home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-30 | 4.6 KB | 179 lines | [TEXT/KAHL] |
- /***********************************************************************************
- CExpandorama.cp
-
- Copyright © 1994 B-Ray Software. All rights reserved.
- Developed using Symantec C++ 7.0.2 and Symantec's TCL library.
- Portions of this code courtesy Symantec, Inc.
-
- This code may be freely distributed as long as this notice remains. This code
- may not be used in any commercial software without the consent of B-Ray Software.
-
- ---
-
- CExpandorama provides functionality like CExpanderPane, but with a Panorama
- twist. For most projects, this would be the root object in an Expander tree. There
- really is no need for more than one of these in a window - all other subpanes
- should be CExpanderPane derivatives.
-
- ***********************************************************************************/
- #include "CExpandorama.h"
- #include "ExpanderMessages.h"
-
-
- TCL_DEFINE_CLASS_D2( CExpandorama, CPanorama, CColumnizer );
-
-
- /*
- * CExpandorama constructor
- *
- * Default constructor - should only be called when created by a file read.
- */
-
- CExpandorama :: CExpandorama() : CPanorama(), CColumnizer()
- {
- TCL_END_CONSTRUCTOR
- }
-
-
- /*
- * CExpandorama constructor
- *
- * Normal constructor - should always be called when created in code.
- */
-
- CExpandorama :: CExpandorama( CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight,
- short aHLoc, short aVLoc,
- SizingOption aHSizing, SizingOption aVSizing )
- : CPanorama( anEnclosure, aSupervisor, aWidth, aHeight, aHLoc, aVLoc,
- aHSizing, aVSizing ), CColumnizer()
- {
- SetWantsClicks( TRUE ); // let user click on us - maybe an Expander present
-
- TCL_END_CONSTRUCTOR
- }
-
-
- /*
- * CExpanderLabel destructor
- *
- * Just a place-holder for Inspector
- */
-
- CExpandorama :: ~CExpandorama()
- {
- TCL_START_DESTRUCTOR
- }
-
-
- /*
- * ChangeSelf method - OVERRIDE
- *
- * Called by CRowColumnMgr whenever a child has changed size. We get the new family size
- * and adjust our bounds to reflect the new size.
- */
-
- void CExpandorama :: ChangeSelf( long changedIndex, Rect *delta )
- {
- LongRect newBounds;
- short aHeight, aWidth;
-
- GetFamilySize( &aWidth, &aHeight );
-
- newBounds.top = 0;
- newBounds.left = 0;
- newBounds.bottom = aHeight / vScale;
- newBounds.right = aWidth / hScale;
- SetBounds( &newBounds );
- Refresh();
-
- TellParent( kRowColChildChanged, delta ); // gotta let our parent know too
- }
-
-
- /*
- * ChildMessage method - OVERRIDE
- *
- * Handles kExpanderChildSelect messages just like CExpanderPane except that we also
- * scroll to the selected child if it is not visible.
- */
-
- void CExpandorama :: ChildMessage( CFamily *aChild, long message, void *param )
- {
- if ( message == kExpanderChildSelect ) {
- if ( itsParent ) { // still can go up the tree
- TellParent( message, param );
- }
- else { // at root of tree - handle it here
- if ( param ) { // we have a valid child
- CPane *aPane = ((CFamily *)param)->ChildToPane(); // get pane for child
- LongRect aFrame;
- aPane->GetFrame( &aFrame ); // get child's frame
- do { // keep converting child's frame to its ancestors
- aPane->FrameToEnclR( &aFrame );
- aPane = (CPane *)(aPane->itsEnclosure);
- } while ( aPane != this ); // until we are reached
-
- MakeSelectionVisible( &aFrame ); // see that the given rect is visible
- }
- TellChildren( message, param ); // pass along the select message to our children
- }
- }
- else {
- CColumnizer::ChildMessage( aChild, message, param );
- }
- }
-
-
- /*
- * MakeSelectionVisible method
- *
- * Makes sure that the given rect is entirely visible in the panorama. If not,
- * it scrolls so that it is.
- */
-
- void CExpandorama :: MakeSelectionVisible( LongRect *rect )
- {
- LongPt newPos;
- short hSpan, vSpan;
- long selectedPos;
-
- GetFrameSpan( &hSpan, &vSpan );
- if ( ( selectedPos = rect->top / vScale ) < position.v ) { // line is above viewable area
- newPos.v = selectedPos;
- newPos.h = position.h;
- ScrollTo( &newPos, TRUE );
- }
- else if ( ( selectedPos = rect->bottom / vScale ) > position.v + vSpan ) { // line is below viewable area
- newPos.v = selectedPos - vSpan;
- newPos.h = position.h;
- ScrollTo( &newPos, TRUE );
- }
- }
-
-
- /*
- * PutTo method - OVERRIDE
- *
- * Writes to the stream all the info we need to save.
- */
-
- void CExpandorama :: PutTo( CStream &stream )
- {
- CPanorama::PutTo( stream ); // let our CPanorama parent access stream
- CColumnizer::PutTo( stream ); // let our CColumnizer parent access stream
- }
-
-
- /*
- * GetFrom method - OVERRIDE
- *
- * Reads from the stream all of the info that we saved.
- */
-
- void CExpandorama :: GetFrom( CStream &stream )
- {
- CPanorama::GetFrom( stream ); // let our CPanorama parent access stream
- CColumnizer::GetFrom( stream ); // let our CColumnizer parent access stream
- }
-